home *** CD-ROM | disk | FTP | other *** search
/ Transactor / Transactor_08_1985_Transactor_Publishing.d64 / star 2.00 < prev    next >
Text File  |  2023-02-26  |  940b  |  44 lines

  1. 0100 // "STAR" - this is a sample comal
  2. 0110 // program to draw a star of any
  3. 0120 // number of points.
  4. 0125 // - comal 2.00 version
  5. 0130 // * transactor magazine - cz *
  6. 0140 use graphics
  7. 0150 use turtle
  8. 0160 splitscreen
  9. 0170 print chr$(147),
  10. 0180 size:=100
  11. 0190 loop
  12. 0200 print chr$(19),
  13. 0210 input"number of points? ":points
  14. 0220 clear
  15. 0230 xstart:=int(160-size/2)
  16. 0240 ystart:=int(100-size/2)
  17. 0250 moveto(xstart,ystart)
  18. 0260 pendown
  19. 0270 star(size,points)
  20. 0280 endloop
  21. 0290 //
  22. 0300 proc star(size, points)
  23. 0310 // ** draw an n-pointed star **
  24. 0320 // first calculate the angle to
  25. 0330 // turn at each point
  26. 0340 case(points mod 4) of
  27. 0350 when 0
  28. 0360 angvar:=points
  29. 0370 when 2
  30. 0380 angvar:=points/2
  31. 0390 otherwise
  32. 0400 angvar:=points*2
  33. 0410 endcase
  34. 0420 angle:=180-360/angvar
  35. 0430 //
  36. 0440 /now draw the star
  37. 0450 setheading((180-angle)/2)
  38. 0460 for i:=1 to points do
  39. 0470 forward(size)
  40. 0480 right(angle)
  41. 0490 endfor i
  42. 0500 endproc star
  43.  
  44.